package com.wwp.tbshop.presenter;

import com.wwp.tbshop.activity.ProductDetailActivity;
import com.wwp.tbshop.model.bean.BaseBean;
import com.wwp.tbshop.model.bean.CollectionBean;

import retrofit2.Call;

/**
 * Created by QIANG on 2017/6/19.
 */

public class CollectionPresenter extends BasePresenter {


    private ProductDetailActivity mProductDetailActivity;

    public CollectionPresenter(ProductDetailActivity productDetailActivity) {
        mProductDetailActivity = productDetailActivity;
    }

    public void addCollectionInfo(String userId, int pId){
        Call<CollectionBean> collectionBeanCall = mApiService.addCollection(userId,pId);
        collectionBeanCall.enqueue(mCallback);
    }

    @Override
    protected void onServerBug(int code) {

    }

    @Override
    protected void onConnectError(String message) {

    }

    @Override
    protected void onSuccess(BaseBean baseBean) {

        String response = baseBean.getResponse();
        if(response.equals("addfavorites")){
            mProductDetailActivity.addCollectionInfo();
        }else {
            mProductDetailActivity.addCollectionInfoError();
        }
    }
}
